<?php
/**
 * QQAS - share your knowledge to the world!
 *
 * @author		xiaochong0302 <xiaochong0302@gmail.com>
 * @copyright	Copyright (c) 2011, Koogua Studio.
 * @license		http://www.qqas.org/user_guide/license.html
 * @link		http://www.qqas.org
 * @since		Version 1.0
 * @filesource
 */


class AnnouncementAction extends HomeAction
{

    protected $Announcement;


    function _initialize()
	{
		parent::_initialize();

		$this->Announcement = D('Announcement');
	}


	public function index()
    {

        import('ORG.Util.Page');

    	$announceID = intval($_GET['aid']);
    	$map = array('announce_id' => $announceID);
    	$result = $this->Announcement->where($map)->order($order)->find();

    	$pageSize = 15;
    	$parameter = '';
    	$map = array();
    	$order = array(
    	   'display_order' => 'asc',
    	   'start_time' => 'desc',
    	);
    	$count = $this->Announcement->where($map)->count();

    	$Page = new Page($count, $pageSize);
		$Page->parameter = $parameter;
		$pagination = $Page->show();
    	$announcements = $this->Announcement->where($map)->order($order)->limit($Page->firstRow.','.$Page->listRows)->select();

        $seo = array(
            'title' => $result['subject'].' - '.L('announcements'),
            'keywords' => $result['subject'],
            'description' => $result['message'],
        );

        $this->assign('seo', $seo);
    	$this->assign('result', $result);
    	$this->assign('announcements', $announcements);
    	$this->assign('pagination', $pagination);
    	$this->display();
    }

}

/* End of file AnnouncementAction.class.php */
/* Location: ./App/Lib/Action/Home/AnnouncementAction.class.php */
